package com.ctgu.expresshelper.controller;

import com.ctgu.expresshelper.entity.Order;
import com.ctgu.expresshelper.service.Order.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @GetMapping("/findAll/{userid}")
    public List<Order> findAll(@PathVariable int userid){
        return orderService.findAll(userid);
    }

    @GetMapping("/findPart/{userid}")
    public List<Order> findPart(@PathVariable int userid){
        return orderService.findPart(userid);
    }

    @RequestMapping("/addOrder")
    @ResponseBody
    public void addOrder(@RequestBody Order order) {
        orderService.addOrder(order);
    }

    @DeleteMapping("/deleteOrder/{id}")
    public void deleteOrder(@PathVariable int id) {
        orderService.deleteOrder(id);
    }
}
